@extends("layout/admin")
@section("css")
    <style type="text/css">
        .img{width: 100%; height: 178.5px; cursor: pointer; background: url("/admins/img/upload.png") 50% 50% no-repeat;}
        .img img{background: #fff; width: 100%;}
    </style>
@endsection
@section("content")
    <div class="row wrapper border-bottom white-bg page-heading">
        <div class="col-lg-10">
            <h2>分类管理</h2>
            <ol class="breadcrumb">
                <li>
                    <a href="/admin">后台管理</a>
                </li>

                <li class="active">
                    <strong>分类列表修改</strong>
                </li>
            </ol>
        </div>
        <div class="col-lg-2">

        </div>
    </div>
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        {{--<h5>All form elements <small>With custom checbox and radion elements.</small></h5>--}}
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="dropdown-toggle" data-toggle="dropdown" href="form_basic.html#">
                                <i class="fa fa-wrench"></i>
                            </a>
                            <ul class="dropdown-menu dropdown-user">
                                <li><a href="form_basic.html#">Config option 1</a>
                                </li>
                                <li><a href="form_basic.html#">Config option 2</a>
                                </li>
                            </ul>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <form method="post" action="/admin/cate-updateRes" class="form-horizontal" enctype="multipart/form-data">
                            <div class="form-group"><label class="col-sm-2 control-label">分类名称</label>

                                <div class="col-sm-10"><input name="name" value="{{$cateData['name']}}" type="text" class="form-control"></div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group"><label class="col-sm-2 control-label">父级分类</label>
                                <div class="col-sm-10">
                                    <select class="form-control m-b" name="pid">
                                        <option value="1">顶级分类</option>
                                        @foreach($cateInfo as $k => $v)
                                            @if($v->id == $cateData['pid'])
                                                <option selected="selected" value="{{$v->id}}">{{$v->name}}</option>
                                            @else
                                                <option value="{{$v->id}}">{{$v->name}}</option>
                                            @endif
                                        @endforeach
                                    </select>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group"><label class="col-sm-2 control-label">备注信息</label>
                                <div class="col-sm-10"><input name="remark" type="text" class="form-control"> <span class="help-block m-b-none"></span>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <button class="btn btn-primary" type="submit">保存</button>
                                </div>
                            </div>
                            <input type="hidden" name="id" value="{{$cateData['id']}}">
                            {{csrf_field()}}
                        </form>
                    </div>
                </div>
            </div>
        </div>
        @endsection
        @section("js")
            <script>
                function upImage(obj){
                    var f = obj[0].files[0];
                    var src = window.URL.createObjectURL(f);
                    if(obj.siblings("img").length == 0){
                        obj.before('<img src="' + src + '" alt="">');
                    }else{
                        obj.siblings("img").attr("src", src);
                    }
                    if(obj.hasClass("images")){
                        $(".delete-buttons").find("div").eq(obj.parents("label").index()).find("button").removeClass("hidden");
                    }
                };
            </script>
@endsection